package 笔试.a空白.b;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
//        int[] a={1,2,3,4};
//        int[] b={};
//        int[] c= mergeOrderNums(a,b);
//        System.out.println(c[3]);
        Scanner sc = new Scanner(System.in);
        String s= sc.nextLine();
        String[] S = s.split(";");
        if(S.length==1){
            String[] split = S[0].split(",");
            System.out.println(split[3]);
            return;
        }else if(S.length==2) {
            String[] m = S[0].split(",");
            int[] a=new int[m.length];
            for (int i = 0; i < m.length; i++){
                a[i]=Integer.parseInt(m[i]);
            }

            String[] z = S[1].split(",");
            int[] b=new int[z.length];
            for (int i = 0; i < z.length; i++){
                b[i]=Integer.parseInt(z[i]);
            }

//            System.out.println(Arrays.toString(a));
//            System.out.println(Arrays.toString(b));
            int[] f= mergeOrderNums(a,b);
            System.out.println(f[3]);
        }
    }
    static int[] mergeOrderNums(int[] L, int[] R) {
        int[] res = new int[L.length + R.length];
        int l=0,r=0, n1=L.length, n2=R.length;

        int i=0;
        while(l<n1 && r<n2){
            if(L[l] <= R[r]){
                res[i++] = L[l++];
            }else {
                res[i++] = R[r++];
            }
        }
        if(l==n1){
            for (int j =r; j<n2 ; j++) {
                res[i++] = R[j];
            }
        }else if(r==n2){
            for (int j = l; j < n1; j++) {
                res[i++] = L[j];
            }
        }
        return res;
    }
}
/*
1,2,3;3,4,5
1,2,3,4,5,6;
 */